package app.web.cartoon.collect;

import cn.lily.com.db.DBFactory;
import cn.lily.com.db.container.reader.DataTable;
import cn.lily.com.db.sql.DBManager;
import cn.lily.com.exception.YaconException;
import cn.lily.esb.enums.EnumManager;
import cn.lily.web.page.BusinessPage;
import cn.lily.web.widget.page.TPanel;
import cn.lily.web.widget.standard.TDrop;
import cn.lily.web.widget.standard.TInput;
/**
 * 动漫详细页面
 * @author JiaJ
 * @date 2017年12月2日
 *
 */
public class CartoonDetailEdit extends BusinessPage {

	 public void page_onLoad() throws YaconException {
		 
		 this.instPanel();

		 this.mainPanel();
		 
		 this.detailPanel();
		 
		 this.otherPanel();

	 }
	 
	 public void instPanel(){
		 
		 TPanel instPanel = Panel("instPanel");
		 instPanel.creatToolbar().setBarText("初始判断信息");
		 
		 TDrop instDrop = new TDrop("INST_DROP");
		 instDrop.setLabel("自建相关信息");	 
		 instDrop.put("0", "否");
		 instDrop.put("1", "是");
		 instDrop.setEditDisabled(true);
		 Form("instForm").createFormCell(instDrop);
		 
		 instPanel.createPanelCell(Form("instForm"));
		 
		 this.getPage().addElement(instPanel);
		 
	 }
	 
	 public void mainPanel(){
		 
		 TPanel cartoonMainPanel = Panel("cartoonMainPanel");
		 cartoonMainPanel.creatToolbar().setBarText("动漫基本信息");

		 Form("cartoonMainForm").setDictTable("LEO_CAN_INFO");
		 
		 //动漫名称
		 Form("cartoonMainForm").createFormCell(Input("CAN_NAME").setEditDisabled(true));
		 Form("cartoonMainForm").createFormRow();		
		 
		 //日文名
		 Form("cartoonMainForm").createFormCell(Input("CAN_NAM_ENG").setEditDisabled(true));
		 Form("cartoonMainForm").createFormRow();

		 //英文名
		 Form("cartoonMainForm").createFormCell(Input("CAN_NAM_JAP").setEditDisabled(true));
		 Form("cartoonMainForm").createFormRow();
		 
		 //动漫首字母
		 Form("cartoonMainForm").createFormCell(Input("CAN_FIRST").setEditDisabled(true));
		 Form("cartoonMainForm").createFormRow();
		 
		 //地区与来源
		 Form("cartoonMainForm").createFormCell(Drop("CAN_AREA").setEditDisabled(true));
		 Form("cartoonMainForm").createFormCell(Drop("CAN_SOURCE").setEditDisabled(true));
		 Form("cartoonMainForm").createFormRow();
		 
		 cartoonMainPanel.createPanelCell(Form("cartoonMainForm"));
		 
		 getPage().addElementRow(cartoonMainPanel);
		 
	 }
	 
	 public void detailPanel(){
		 
		 TPanel cartoonDetailPanel = Panel("cartoonDetailPanel");
		 cartoonDetailPanel.creatToolbar().setBarText("动漫明细信息");
		 
		 Form("cartoonDetailForm").setDictTable("LEO_CAN_DETAIL_INFO,LEO_RES_INFO");
		 
		 Form("cartoonDetailForm").createFormCell(Input("CAN_DETAIL_NAME"));
		 Form("cartoonDetailForm").createFormRow();
		 
		 Form("cartoonDetailForm").createFormCell(Drop("CAN_KIND"));
		 Form("cartoonDetailForm").createFormCell(Drop("CAN_QUA"));
		 Form("cartoonDetailForm").createFormRow();

		 Form("cartoonDetailForm").createFormCell(Drop("CAN_STAT"));
		 Form("cartoonDetailForm").createFormCell(Input("CAN_TOTAL"));
		 Form("cartoonDetailForm").createFormRow();
		 
		 TInput timeInput = Input("CAN_TIME_FIX");
		 timeInput.setLabel("上市时间");
		 Form("cartoonDetailForm").createFormCell(timeInput);
		 
		 Form("cartoonDetailForm").createFormCell(Input("CAN_TYP_MEMO"));
		 Form("cartoonDetailForm").createFormRow();
		 
		 TDrop diskDrop = Drop("DISK_ID");
		 diskDrop.setLabel("硬盘信息");
		 
		 String state = this.getAttr("state");
		 if("insert".equals(state)){
			 diskDrop.setEnumDetail(EnumManager.getDBEnum("select DISK_ID,DISK_NAM from ${schema}.LEO_DISK_INFO where DISK_STATUS='1' order by DISK_ID DESC"));			 
		 }else{
			 diskDrop.setEnumDetail(EnumManager.getDBEnum("select DISK_ID,DISK_NAM from ${schema}.LEO_DISK_INFO order by DISK_ID DESC"));			 
		 }
		 
		 Form("cartoonDetailForm").createFormCell(diskDrop);
		 
		 Form("cartoonDetailForm").createFormCell(Input("RES_STORE_SIZE"));
		 Form("cartoonDetailForm").createFormRow();
		 	 
		 Form("cartoonDetailForm").createFormCell(Input("RES_STORE_PLACE"));
		 Form("cartoonDetailForm").createFormRow();

		 Form("cartoonDetailForm").createFormCell(TextArea("CAN_DEMO").setAreaRow(9));
		 Form("cartoonDetailForm").createFormRow();
		 
		 cartoonDetailPanel.createPanelCell(Form("cartoonDetailForm"));
		 
		 getPage().addElementRow(cartoonDetailPanel);
		 
	 }
	 
	 public void otherPanel(){
		 TPanel cartoonOtherForm = Panel("cartoonOtherPanel");
		 cartoonOtherForm.creatToolbar().setBarText("动漫其他信息");
		 
		 Form("cartoonOtherForm").setDictTable("LEO_CAN_DETAIL_INFO,LEO_RES_INFO");
		 
		 Form("cartoonOtherForm").createFormCell(Input("CAN_FIRM_MEMO"));
		 Form("cartoonOtherForm").createFormRow();
		 
		 Form("cartoonOtherForm").createFormCell(Input("RES_TAG_MEMO"));
		 Form("cartoonOtherForm").createFormRow();
		 
		 cartoonOtherForm.createPanelCell(Form("cartoonOtherForm"));
		 
		 cartoonOtherForm.creatStatusBar().addElement(Button("save"));
		 cartoonOtherForm.getStatusBar().addElement(Button("exit"));
		 getPage().addElementRow(cartoonOtherForm);
	 }

	 public void loadData(){
		 String canID = "";
		 if(this.getViewTable().next()){
			 canID = this.getViewTable().getString("canID");
		 }
		 
		 DBManager dbManager = DBFactory.getActionDB();
		 DataTable dt = dbManager.executeQueryTable("select * from ${schema}.LEO_CAN_INFO where CAN_ID='"+canID+"'");
		 this.setDataTable(dt);
		 
	 }
	 
}
